<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>指尖改变世界 - 科技始终来源于人性</title><meta name="keywords" content="沙屿沫个人博客,沙屿沫,shayvmo,php"><meta name="author" content="沙屿沫"><meta name="copyright" content="沙屿沫"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="科技始终来源于人性">
<meta property="og:type" content="website">
<meta property="og:title" content="指尖改变世界">
<meta property="og:url" content="http://blog.shayvmo.cn/page/3/index.html">
<meta property="og:site_name" content="指尖改变世界">
<meta property="og:description" content="科技始终来源于人性">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://blog.shayvmo.cn/images/avatar.jpg">
<meta property="article:author" content="沙屿沫">
<meta property="article:tag" content="沙屿沫个人博客,沙屿沫,shayvmo,php">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://blog.shayvmo.cn/images/avatar.jpg"><link rel="shortcut icon" href="/images/avatar.jpg"><link rel="canonical" href="http://blog.shayvmo.cn/page/3/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?5e4d1e8fcc524b4e732ea58fa9fa15f0";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '指尖改变世界',
  isPost: false,
  isHome: true,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2023-06-05 17:19:25'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    })(window)</script><meta name="generator" content="Hexo 5.4.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src= "" data-lazy-src="/images/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">74</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">42</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">15</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="page" id="body-wrap"><header class="full_page" id="page-header" style="background-image: url('/images/bg/kobe.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">指尖改变世界</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">指尖改变世界</h1><div id="site-subtitle"><span id="subtitle"></span></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/07/29/quick-sort/" title="排序算法 - 快速排序">     <img class="post_bg" src= "" data-lazy-src="/images/code.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="排序算法 - 快速排序"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/07/29/quick-sort/" title="排序算法 - 快速排序">排序算法 - 快速排序</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-07-29T03:14:52.000Z" title="发表于 2021-07-29 11:14:52">2021-07-29</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95/">数据结构与算法</a></span></div><div class="content">快速排序
选择一个基准数，通过一趟排序将要排序的数据分割成独立的两部分；其中一部分的所有数据都比另外一部分的所有数据都要小。然后，再按此方法对这两部分数据分别进行快速排序，整个排序过程可以递归进行，以此达到整个数据变成有序序列。

选择一个基准数，小值在左，大值在右，递归左子数列和右子数列
核心思想是分治法，分而治之
单边扫描
我们随意抽取一个数作为基准值，同时设定一个标记 mark 代表左边序列最右侧的下标位置，当然初始为 0 ，接下来遍历数组，如果元素大于基准值，无操作，继续遍历，如果元素小于基准值，则把 mark + 1 ，再将 mark 所在位置的元素和遍历到的元素交换位置，mark 这个位置存储的是比基准值小的数据，当遍历结束后，将基准值与 mark 所在元素交换位置即可。

遍历数列后，mark 下标所在元素为数列中，小于基准值的最右侧元素，此时mark下标左侧数列包含基准值，交换基准值和mark位置元素后，基准值位置左侧的所有元素都是小于基准值，右侧所有元素都是大于基准值
代码实现function quick_sort_1(array &amp;$arr, $start_ ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/07/27/bubble-sort/" title="排序算法 - 冒泡排序">     <img class="post_bg" src= "" data-lazy-src="/images/code.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="排序算法 - 冒泡排序"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/07/27/bubble-sort/" title="排序算法 - 冒泡排序">排序算法 - 冒泡排序</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-07-27T09:57:08.000Z" title="发表于 2021-07-27 17:57:08">2021-07-27</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95/">数据结构与算法</a></span></div><div class="content">冒泡排序 Bubble-sort
简单的排序算法，遍历多次需要排序的数列。每次遍历时，它都会从前往后依次的比较相邻两个数的大小；如果前者比后者大，则交换它们的位置。这样，一次遍历之后，最大的元素就在数列的末尾！ 采用相同的方法再次遍历时，第二大的元素就被排列在最大元素之前。重复此操作，直到整个数列都有序为止！

代码实现function bubble_sort(array $arr)&#123;    if (count($arr) &lt;= 1) &#123;        return $arr;    &#125;    for ($i = 0; $i &lt; count($arr) - 1; $i++) &#123;        $sort = false;        for ($j = 0; $j &lt; count($arr) - $i - 1; $j++) &#123;            if ($arr[$j] &gt; $arr[$j + 1]) &#123;                $temp = $arr[$j + 1];           ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/07/20/strrev/" title="PHP实现字符串反转">     <img class="post_bg" src= "" data-lazy-src="/images/php.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="PHP实现字符串反转"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/07/20/strrev/" title="PHP实现字符串反转">PHP实现字符串反转</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-07-20T03:27:43.000Z" title="发表于 2021-07-20 11:27:43">2021-07-20</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/PHP/">PHP</a></span></div><div class="content">最小代价实现将字符串完全反序, e.g. 将 “1234567890” 转换成 “0987654321”
要实现字符串反转，有两种方式：

PHP自带函数

不使用函数（循环）


使用 PHP 自带函数$a = &#x27;1234567890&#x27;;// 输出 0987654321echo strrev($a);

不使用函数（循环）$str = &#x27;&#x27;;$i = 0;while( isset($a[$i]) &amp;&amp; !is_null($a[$i])) &#123;    $str = $a[$i++].$str;&#125;// 输出 0987654321echo $str;


拓展上面两种方式，反转含有中文的字符串时，会因为编码出现乱码问题。
解决：
mb 系列函数没有直接实现反转的函数，于是用循环的方式去实现。
$a = &#x27;@#￥（*&amp;中文一段abcdefg^&#x27;;function my_strrev(string $string) &#123;    if (empty($string)) &#123;    ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/07/12/why-403/" title="403可能出现的原因是什么?怎么解决?">     <img class="post_bg" src= "" data-lazy-src="/images/code.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="403可能出现的原因是什么?怎么解决?"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/07/12/why-403/" title="403可能出现的原因是什么?怎么解决?">403可能出现的原因是什么?怎么解决?</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-07-12T13:31:18.000Z" title="发表于 2021-07-12 21:31:18">2021-07-12</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/">计算机网络</a></span></div><div class="content">403可能出现的原因是什么?一、启动用户和 nginx 工作用户不一致查看运行 nginx 的用户
# 输出启动用户ps aux | grep &quot;nginx: worker process&quot; | awk &#x27;&#123;print $1&#125;&#x27;

解析：
ps 查看进程
ps a 显示现行终端的所有程序
ps u 以用户为主的格式显示程序状态
ps x 显示所有程序，不以终端机来区分
grep 搜索匹配
awk 文本分析，上述例子中，每行按空格或TAB分割，输出文本中的第1项
修改 nginx.config 的用户
vi /etc/nginx/nginx.conf


二、缺少 index.html 或 index.phpnginx 配置文件中 server 块配置目录找不到 index 的文件
server &#123;    listen 80;    server_name localhost;    root /www/;    index index.php index.html;&#125;


三、权限问题nginx 没有操作配 ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/06/30/js-click-copy/" title="js-click-copy, js实现点击按钮复制文本功能">     <img class="post_bg" src= "" data-lazy-src="/images/code.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="js-click-copy, js实现点击按钮复制文本功能"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/06/30/js-click-copy/" title="js-click-copy, js实现点击按钮复制文本功能">js-click-copy, js实现点击按钮复制文本功能</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-06-30T08:48:57.000Z" title="发表于 2021-06-30 16:48:57">2021-06-30</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E5%89%8D%E7%AB%AF/">前端</a></span></div><div class="content">系统开发中，有些业务场景需要用到，点击按钮复制文本到键盘的 ctrl + v粘贴板的功能，于是记录一下自己的实现过程。
【整体思路】获取到某个 input 或者 textarea 的 dom后, 选中当前 dom, 执行浏览器复制命令。
这里有几个点需要注意：
1、dom 必须要input或者 textarea
2、dom 必须是可见的，这里的可见指的是display可见，也就是说hidden和display: none是复制不到的
3、当需要复制的内容不是input或者textarea，可以通过创建一个dom，把相应的值赋值到这个dom后，再进行执行复制命令
另外，在第2点的基础上，如果这个dom实际上我们并不想它展示在用户的面前，可以使用定位的方式，隐藏到所有元素的最底层。
示例：
let dom = document.getElementById(id)dom.select()document.execCommand(&#x27;Copy&#x27;)

</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/06/28/php-cli/" title="php-cli,php 命令行运行模式参数传递">     <img class="post_bg" src= "" data-lazy-src="/images/php.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="php-cli,php 命令行运行模式参数传递"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/06/28/php-cli/" title="php-cli,php 命令行运行模式参数传递">php-cli,php 命令行运行模式参数传递</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-06-28T07:46:59.000Z" title="发表于 2021-06-28 15:46:59">2021-06-28</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/PHP/">PHP</a></span></div><div class="content">PHP 命令行运行模式参数传递
传递给脚本的参数可以在全局变量 $argv 中获取。
全局变量 $argc 表示 $argv 数组中的元素个数。
示例:
php index.php a b

上述例子中，$argv 为以下结构,$argc则是 3
[    &#x27;index.php&#x27;,    &#x27;a&#x27;,    &#x27;b&#x27;]

</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/05/27/slow-array-func-used-in-loop/" title="slow-array-func-used-in-loop 【 PHP 循环结构中使用数组函数 】">     <img class="post_bg" src= "" data-lazy-src="/images/php.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="slow-array-func-used-in-loop 【 PHP 循环结构中使用数组函数 】"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/05/27/slow-array-func-used-in-loop/" title="slow-array-func-used-in-loop 【 PHP 循环结构中使用数组函数 】">slow-array-func-used-in-loop 【 PHP 循环结构中使用数组函数 】</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-05-27T10:17:38.000Z" title="发表于 2021-05-27 18:17:38">2021-05-27</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/PHP/">PHP</a></span></div><div class="content">循环里面使用 array 相关函数会导致运行慢，且占用CPU
例如：
$options = [];foreach ($configurationSources as $source) &#123;    /* something happens here */    $options = array_merge($options, $source-&gt;getOptions());&#125;

以上代码可以优化成：
$options = [];foreach ($configurationSources as $source) &#123;    /* something happens here */    $options[] = $source-&gt;getOptions(); // &lt;- yes, we&#x27;ll use a little bit more memory&#125;/* PHP below 5.6 */$options = call_user_func_array(&#x27;array_merge&#x27;, $options + [[]] ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/05/19/element-input/" title="element-ui, el-input 监听回车事件，阻止冒泡">     <img class="post_bg" src= "" data-lazy-src="/images/vue.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="element-ui, el-input 监听回车事件，阻止冒泡"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/05/19/element-input/" title="element-ui, el-input 监听回车事件，阻止冒泡">element-ui, el-input 监听回车事件，阻止冒泡</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-05-19T10:32:18.000Z" title="发表于 2021-05-19 18:32:18">2021-05-19</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E5%89%8D%E7%AB%AF/">前端</a></span></div><div class="content">el-form 阻止冒泡
@submit.native.prevent
例子：
&lt;el-form :inline=&quot;true&quot; :model=&quot;couponSearchForm&quot; class=&quot;demo-form-inline&quot; @submit.native.prevent&gt;    &lt;el-form-item label=&quot;关键词&quot;&gt;        &lt;el-input        v-model=&quot;couponSearchForm.keyword&quot;        clearable        @clear=&quot;resetCouponSearch&quot;        placeholder=&quot;&quot;        @input=&quot;autoSearchUserCoupon&quot;        &gt;&lt;/el-input&gt;    &lt;/el-form-item&gt;    &lt;el-for ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/2021/05/18/element-table/" title="element el-table 数据源的值改变后，表格不刷新，没有重新渲染">     <img class="post_bg" src= "" data-lazy-src="/images/vue.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="element el-table 数据源的值改变后，表格不刷新，没有重新渲染"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/05/18/element-table/" title="element el-table 数据源的值改变后，表格不刷新，没有重新渲染">element el-table 数据源的值改变后，表格不刷新，没有重新渲染</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-05-18T10:25:19.000Z" title="发表于 2021-05-18 18:25:19">2021-05-18</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E5%89%8D%E7%AB%AF/">前端</a></span></div><div class="content">列表查询页面，通常会使用 el-table 进行列表的数据渲染，请求更新触发更新 table 的数据源是可以实现的。
当 el-table 用于属性计算时，比如说 sku 属性计算，这时候可能会出现数据源的值改变后，表格不刷新，没有重新渲染
这时候，可以在table 的 key 上，绑定设置一个动态的值，每次源数据刷新时，刷新 key 值
:key=&quot;key&quot;
key 随机生成即可。
key=Math.random()



</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/2021/04/25/php-switch/" title="php-switch case 比较问题">     <img class="post_bg" src= "" data-lazy-src="/images/php.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="php-switch case 比较问题"></a></div><div class="recent-post-info"><a class="article-title" href="/2021/04/25/php-switch/" title="php-switch case 比较问题">php-switch case 比较问题</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-04-25T10:37:51.000Z" title="发表于 2021-04-25 18:37:51">2021-04-25</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/PHP/">PHP</a></span></div><div class="content">刚好有个朋友在群上提到了这个问题，于是查询手册后总结一下。
错误例子：

上述例子中，会出现比对错误。
1、case 比对用的是松散比较。2、case 求值后，都为true 或者false
当 $num =  0 时， 0 和 false 松散比较为 true ，于是，会和第二个 case 匹配成功。
【总结】1、case 最好是恒定的情况2、考虑松散比较的问题，最好不要使用1 和 ‘1’ 这种简单的比对
</div></div></div><nav id="pagination"><div class="pagination"><a class="extend prev" rel="prev" href="/page/2/#content-inner"><i class="fas fa-chevron-left fa-fw"></i></a><a class="page-number" href="/">1</a><a class="page-number" href="/page/2/#content-inner">2</a><span class="page-number current">3</span><a class="page-number" href="/page/4/#content-inner">4</a><span class="space">&hellip;</span><a class="page-number" href="/page/8/#content-inner">8</a><a class="extend next" rel="next" href="/page/4/#content-inner"><i class="fas fa-chevron-right fa-fw"></i></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" src= "" data-lazy-src="/images/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">沙屿沫</div><div class="author-info__description">科技始终来源于人性</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">74</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">42</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">15</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/shayvmo"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">生活就像海洋，只有意志坚强的人才能到达彼岸。</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2023/06/05/webman-route-annotation/" title="webman 框架 注解路由插件"><img src= "" data-lazy-src="/images/code.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="webman 框架 注解路由插件"/></a><div class="content"><a class="title" href="/2023/06/05/webman-route-annotation/" title="webman 框架 注解路由插件">webman 框架 注解路由插件</a><time datetime="2023-06-05T07:04:07.000Z" title="发表于 2023-06-05 15:04:07">2023-06-05</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/05/29/nginx-reload-not-effect/" title="windows服务器重载nginx配置无效"><img src= "" data-lazy-src="/images/code.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="windows服务器重载nginx配置无效"/></a><div class="content"><a class="title" href="/2023/05/29/nginx-reload-not-effect/" title="windows服务器重载nginx配置无效">windows服务器重载nginx配置无效</a><time datetime="2023-05-29T08:03:45.000Z" title="发表于 2023-05-29 16:03:45">2023-05-29</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/05/24/php-aes/" title="前后端接口传输AES加密"><img src= "" data-lazy-src="/images/code.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="前后端接口传输AES加密"/></a><div class="content"><a class="title" href="/2023/05/24/php-aes/" title="前后端接口传输AES加密">前后端接口传输AES加密</a><time datetime="2023-05-24T07:00:39.000Z" title="发表于 2023-05-24 15:00:39">2023-05-24</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/08/16/yar-demo/" title="Yar拓展，实现PHP的RPC服务"><img src= "" data-lazy-src="/images/code.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Yar拓展，实现PHP的RPC服务"/></a><div class="content"><a class="title" href="/2022/08/16/yar-demo/" title="Yar拓展，实现PHP的RPC服务">Yar拓展，实现PHP的RPC服务</a><time datetime="2022-08-16T09:30:43.000Z" title="发表于 2022-08-16 17:30:43">2022-08-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/08/15/my-online-log/" title="线上日志系统"><img src= "" data-lazy-src="/images/code.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="线上日志系统"/></a><div class="content"><a class="title" href="/2022/08/15/my-online-log/" title="线上日志系统">线上日志系统</a><time datetime="2022-08-15T09:03:01.000Z" title="发表于 2022-08-15 17:03:01">2022-08-15</time></div></div></div></div><div class="card-widget card-categories"><div class="item-headline">
            <i class="fas fa-folder-open"></i>
            <span>分类</span>
            <a class="card-more-btn" href="/categories/" title="查看更多">
    <i class="fas fa-angle-right"></i></a>
            </div>
            <ul class="card-category-list" id="aside-cat-list">
            <li class="card-category-list-item "><a class="card-category-list-link" href="/categories/Go/"><span class="card-category-list-name">Go</span><span class="card-category-list-count">4</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/Hexo/"><span class="card-category-list-name">Hexo</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/Java/"><span class="card-category-list-name">Java</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/Linux/"><span class="card-category-list-name">Linux</span><span class="card-category-list-count">9</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/Memcached/"><span class="card-category-list-name">Memcached</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/MySQL/"><span class="card-category-list-name">MySQL</span><span class="card-category-list-count">3</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/PHP/"><span class="card-category-list-name">PHP</span><span class="card-category-list-count">23</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/Redis/"><span class="card-category-list-name">Redis</span><span class="card-category-list-count">1</span></a></li>
            </ul></div><div class="card-widget card-tags"><div class="item-headline"><i class="fas fa-tags"></i><span>标签</span></div><div class="card-tag-cloud"><a href="/tags/AES/" style="font-size: 1.1em; color: #999">AES</a> <a href="/tags/Apache/" style="font-size: 1.1em; color: #999">Apache</a> <a href="/tags/Curl/" style="font-size: 1.1em; color: #999">Curl</a> <a href="/tags/Go/" style="font-size: 1.37em; color: #99a4b2">Go</a> <a href="/tags/Hexo/" style="font-size: 1.37em; color: #99a4b2">Hexo</a> <a href="/tags/Laravel/" style="font-size: 1.1em; color: #999">Laravel</a> <a href="/tags/Linux/" style="font-size: 1.1em; color: #999">Linux</a> <a href="/tags/MD5/" style="font-size: 1.1em; color: #999">MD5</a> <a href="/tags/MySQL/" style="font-size: 1.37em; color: #99a4b2">MySQL</a> <a href="/tags/Nginx/" style="font-size: 1.23em; color: #999ea6">Nginx</a> <a href="/tags/PHP/" style="font-size: 1.5em; color: #99a9bf">PHP</a> <a href="/tags/Paypal/" style="font-size: 1.1em; color: #999">Paypal</a> <a href="/tags/PhpStorm/" style="font-size: 1.1em; color: #999">PhpStorm</a> <a href="/tags/Python/" style="font-size: 1.1em; color: #999">Python</a> <a href="/tags/RESTfulAPI/" style="font-size: 1.1em; color: #999">RESTfulAPI</a> <a href="/tags/RPC/" style="font-size: 1.1em; color: #999">RPC</a> <a href="/tags/Redis/" style="font-size: 1.1em; color: #999">Redis</a> <a href="/tags/SVN/" style="font-size: 1.1em; color: #999">SVN</a> <a href="/tags/Ubuntu/" style="font-size: 1.37em; color: #99a4b2">Ubuntu</a> <a href="/tags/Vagrant/" style="font-size: 1.23em; color: #999ea6">Vagrant</a> <a href="/tags/Websocket/" style="font-size: 1.1em; color: #999">Websocket</a> <a href="/tags/Yii/" style="font-size: 1.1em; color: #999">Yii</a> <a href="/tags/composer/" style="font-size: 1.1em; color: #999">composer</a> <a href="/tags/element/" style="font-size: 1.23em; color: #999ea6">element</a> <a href="/tags/git/" style="font-size: 1.1em; color: #999">git</a> <a href="/tags/jquery/" style="font-size: 1.1em; color: #999">jquery</a> <a href="/tags/memcached/" style="font-size: 1.1em; color: #999">memcached</a> <a href="/tags/postman/" style="font-size: 1.1em; color: #999">postman</a> <a href="/tags/sitemap/" style="font-size: 1.1em; color: #999">sitemap</a> <a href="/tags/thinkphp6/" style="font-size: 1.1em; color: #999">thinkphp6</a> <a href="/tags/vue/" style="font-size: 1.1em; color: #999">vue</a> <a href="/tags/webhooks/" style="font-size: 1.1em; color: #999">webhooks</a> <a href="/tags/webman/" style="font-size: 1.1em; color: #999">webman</a> <a href="/tags/%E5%85%AC%E4%BC%97%E5%8F%B7%E8%B0%83%E8%AF%95%E5%99%A8/" style="font-size: 1.1em; color: #999">公众号调试器</a> <a href="/tags/%E5%86%92%E6%B3%A1%E6%8E%92%E5%BA%8F/" style="font-size: 1.1em; color: #999">冒泡排序</a> <a href="/tags/%E5%8D%9A%E5%AE%A2%E8%BF%81%E7%A7%BB/" style="font-size: 1.1em; color: #999">博客迁移</a> <a href="/tags/%E5%9B%BE%E7%89%87%E8%BD%ACbase64/" style="font-size: 1.1em; color: #999">图片转base64</a> <a href="/tags/%E5%B7%A5%E5%85%B7/" style="font-size: 1.1em; color: #999">工具</a> <a href="/tags/%E5%B9%82%E7%AD%89/" style="font-size: 1.1em; color: #999">幂等</a> <a href="/tags/%E6%B3%9B%E5%9E%8B/" style="font-size: 1.1em; color: #999">泛型</a></div></div><div class="card-widget card-archives"><div class="item-headline"><i class="fas fa-archive"></i><span>归档</span><a class="card-more-btn" href="/archives/" title="查看更多">
    <i class="fas fa-angle-right"></i></a></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2023/06/"><span class="card-archive-list-date">六月 2023</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2023/05/"><span class="card-archive-list-date">五月 2023</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2022/08/"><span class="card-archive-list-date">八月 2022</span><span class="card-archive-list-count">4</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2022/06/"><span class="card-archive-list-date">六月 2022</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2022/05/"><span class="card-archive-list-date">五月 2022</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2022/01/"><span class="card-archive-list-date">一月 2022</span><span class="card-archive-list-count">6</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/09/"><span class="card-archive-list-date">九月 2021</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/08/"><span class="card-archive-list-date">八月 2021</span><span class="card-archive-list-count">1</span></a></li></ul></div><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>网站资讯</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">文章数目 :</div><div class="item-count">74</div></div><div class="webinfo-item"><div class="item-name">已运行时间 :</div><div class="item-count" id="runtimeshow" data-publishDate="2019-08-27T16:00:00.000Z"></div></div><div class="webinfo-item"><div class="item-name">本站总字数 :</div><div class="item-count">30.9k</div></div><div class="webinfo-item"><div class="item-name">本站访客数 :</div><div class="item-count" id="busuanzi_value_site_uv"></div></div><div class="webinfo-item"><div class="item-name">本站总访问量 :</div><div class="item-count" id="busuanzi_value_site_pv"></div></div><div class="webinfo-item"><div class="item-name">最后更新时间 :</div><div class="item-count" id="last-push-date" data-lastPushDate="2023-06-05T09:19:25.031Z"></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('/images/bg/kobe.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2019 - 2023 By 沙屿沫</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><a href="http://www.beian.miit.gov.cn/" target="_blank" rel="noopener"><img class="icp-icon" src= "" data-lazy-src="/images/icp.png"><span>粤ICP备18133330号</span></a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>function subtitleType () {
  if (true) { 
    var typed = new Typed("#subtitle", {
      strings: "生活就像海洋，只有意志坚强的人才能到达彼岸".split(","),
      startDelay: 300,
      typeSpeed: 150,
      loop: true,
      backSpeed: 50
    })
  } else {
    document.getElementById("subtitle").innerHTML = '生'
  }
}

if (true) {
  if (typeof Typed === 'function') {
    subtitleType()
  } else {
    getScript('https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js').then(subtitleType)
  }
} else {
  subtitleType()
}</script></div><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="false" data-click="false"></script><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><script id="click-show-text" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-show-text.min.js" data-mobile="false" data-text="富强,民主,文明,和谐,自由,平等,公正,法治,爱国,敬业,诚信,友善" data-fontsize="15px" data-random="false" async="async"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>